module sdldee.video.windowmanager;

import std.string;

import sdldee.c.sdl;
import sdldee.video.surface;
import sdldee.video.videosurface;
import sdldee.video.exception;

void setCaption(char[] title, char[] icon) {
	SDL_WM_SetCaption(toStringz(title), toStringz(icon));
}

void getCaption(out char[] title, out char[] icon) {
	char* ctitle, cicon;
	SDL_WM_GetCaption(&ctitle, &cicon);
	title = std.string.toString(ctitle);
	icon = std.string.toString(cicon);
}

void setIcon(Surface icon, ubyte mask) {
	SDL_WM_SetIcon(icon.csurface, &mask);
}

void setIcon(Surface icon) {
	SDL_WM_SetIcon(icon.csurface, null);
}

void iconifyWindow() {
	if(SDL_WM_IconifyWindow() != 0)
		throw new VideoException("Unable to iconify window");
}

void toggleFullscreen(VideoSurface video) {
	if(SDL_WM_ToggleFullScreen(video.csurface()) != 1)
		throw new VideoException("Unable to toggle fullscreen");
}

void toggleFullscreen() {
	toggleFullscreen(VideoSurface.videoSurface);
}

enum GrabMode {
	QUERY = -1,
	GRAB_OFF = 0,
	GRAB_ON = 1,
	GRAB_FULLSCREEN	/* Used internally */
}

GrabMode grabInput(GrabMode mode) {
	return cast(GrabMode) SDL_WM_GrabInput(mode);
}
